#include <all_gd.h>
#pragma hdrstop
//#pragma package(smart_init)
#pragma resource "*.dfm"

#include "int.h"
#include "gf_Handler.h"

//---------------------------------------------------------------------------
__fastcall TGrifinHandlerForm::TGrifinHandlerForm(TComponent* Owner)
    : TForm(Owner)
  {
}

bool TGrifinHandlerForm::IsValid( void )
  {
     hWnd = ::FindWindow( NULL, "Syntetic Vision - Gryffin" );
     if ( hWnd != NULL ) {
       Timer->Enabled = true;
       return true;
     } else {
       Timer->Enabled = false;
       return false;
     }
}
void __fastcall TGrifinHandlerForm::WndProc( Messages::TMessage& m )
  {
     if ( m.Msg == WM_COPYDATA ) {
       PCOPYDATASTRUCT cd = (PCOPYDATASTRUCT)m.LParam;
       if ( cd->dwData == WM_GET_LOCATION ) {
         Index++;
         Response = *(GetLocationResponse*)cd->lpData;
       }
     } else
       TForm::WndProc( m );
}
//---------------------------------------------------------------------------
void __fastcall TGrifinHandlerForm::TimerTimer(TObject *Sender)
  {
     if ( IsValid() )
       PostMessage( hWnd, WM_GET_LOCATION, (WPARAM)Handle, 0 );
}
//---------------------------------------------------------------------------
